/*
 * SHOPTNT 版权所有。
 * 未经许可，您不得使用此文件。
 * 官方地址：www.shoptnt.cn
 */
package cn.shoptnt.framework.parameter;

import cn.shoptnt.framework.ShopTntConfig;
import cn.shoptnt.framework.cache.Cache;
import cn.shoptnt.framework.util.StringUtil;
import cn.shoptnt.framework.util.TokenKeyGenerate;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

/**
 * 入参拦截,对request重新包装，目前只处理了emoji表情的拦截
 * @author fk
 * @version v2.0
 * @since v7.2.0
 * 2020.5.8
 */
public class ParameterFilter implements Filter{


    @Autowired
    private ShopTntConfig shoptntConfig;

    public ParameterFilter(ShopTntConfig shoptntConfig) {
        this.shoptntConfig = shoptntConfig;
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
    }


    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        EmojiEncodeRequestWrapper emojiRequest= new EmojiEncodeRequestWrapper((HttpServletRequest)request);
        chain.doFilter(emojiRequest, response);
    }

    @Override
    public void destroy() {

    }

}
